#include <iostream>
#include <string>
#include <cmath>

using namespace std;

class Circle
{
private:
    float R;
    float X;
    float Y;
public:
    //构造函数 初始化列表
    Circle(float r,float x,float y)
    : R(r), X(x), Y(y)
    {
        if(r < 0)
        {
            r = 0;
            cerr << "半径不能为负 已自动设为0" << endl; 
        }
    }

    //返回半径
    float getr() const
    {
        return R;
    }

    //返回直径
    float getd() const
    {
        return 2 * R;
    }

    //返回周长
    float getC() const
    {
        return 2 * M_PI * R;
    }

    //返回面积
    float getS() const
    {
        return M_PI * pow( R , 2 );
    }

    //返回x
    void setx(float x)
    {
        X = x;
    }

    //返回y
    void sety(float y)
    {
        X = y;
    }

       //返回圆心
    void getcenter()
    {
        cout << "圆心:" << "(" << X << " , " << Y << ")" << endl;
    }

    // 判定两个圆是否相切
    // 通过计算两个圆心之间的距离，判断是否等于两个圆半径之和或差
    string areTangential(const Circle& other) const {
        // 计算两个圆心之间的距离
        float distance = sqrt(std::pow(X - other.X, 2) + pow(Y - other.Y, 2));
        // 如果距离等于两个圆半径之和或差，则认为相切
        if(distance == (R + other.R))
        {
            return "两个圆外切";
        }
        else if(distance == abs(R - other.R) && distance != 0)
        {
            return "两个圆内切";
        }
        else if(distance == 0 && R == other.R)
        {
            return "两个圆完全重合";
        }
    }
};


int main(int argc, char const *argv[])
{
    Circle C1(5,0,0);
    Circle C2(5,0,0);
    
    cout << "C1:" << endl;
    cout << "周长:" << C1.getC() << endl;
    cout << "面积:" << C1.getS() << endl;
    cout << "直径:" << C1.getd() << endl;
    C1.getcenter();
    
    cout << "C2:" << endl;
    cout << "周长:" << C2.getC() << endl;
    cout << "面积:" << C2.getS() << endl;
    cout << "直径:" << C2.getd() << endl;
    C2.getcenter();

    cout << C1.areTangential(C2) << endl;
    return 0;
}
